package lg.minecraft.plugin.pokemonmenu.config.builder;

import lg.minecraft.plugin.cobblemoncore.util.PokemonPlaceholderReplacer;
import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.List;
import java.util.Map;

/**
 * @author langle__
 * @version 1.0
 */
public class PlaceholderItemBuilder {

    private final Material material;
    private final String name;
    private final List<String> lore;

    public PlaceholderItemBuilder(Material material, String name, List<String> lore) {
        this.material = material;
        this.name = name;
        this.lore = lore;
    }

    public ItemStack build(Map<String, String> map) {
        ItemStack stack = new ItemStack(material);
        ItemMeta meta = stack.getItemMeta();
        if (meta != null) {
            meta.setDisplayName(PokemonPlaceholderReplacer.replacePlaceholders(name, map));
            meta.setLore(PokemonPlaceholderReplacer.replacePlaceholders(lore, map));
            meta.addItemFlags(ItemFlag.values());
            stack.setItemMeta(meta);
        }
        return stack;
    }

}
